package cn.stylefeng.guns.modular.system.service.impl;

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.stylefeng.guns.modular.system.dao.CollectorsAssociationMapper;
import cn.stylefeng.guns.modular.system.entity.CollectorsAssociation;
import cn.stylefeng.guns.modular.system.service.CollectorsAssociationService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @ClassName CollectorsAssociationServiceImpl
 * @Author lzy
 * @Date 2020/2/27 22:14
 * @VERSION 1.0
 */
@Service
public class CollectorsAssociationServiceImpl extends ServiceImpl<CollectorsAssociationMapper, CollectorsAssociation> implements CollectorsAssociationService {
    @Autowired
    private CollectorsAssociationMapper collectorsAssociationMapper;

    @Override
    public List<CollectorsAssociation> findAssociation(String joinStartTime, String joinEndTime, String province,
                                                       String memberName, String contactAddress, String collectionRange,
                                                       String renewalPaymentStartTime, String renewalPaymentEndTime,
                                                       String mobileNumber, String startAge, String endAge, String sex) {

        if(!ObjectUtils.isEmpty(province)){
            province = "%" + province + "%";
        }

        if(!ObjectUtils.isEmpty(memberName)){
            memberName = "%" + memberName + "%";
        }

        if(!ObjectUtils.isEmpty(contactAddress)){
            contactAddress = "%" + contactAddress + "%";
        }

        if(!ObjectUtils.isEmpty(collectionRange)){
            collectionRange = "%" + collectionRange + "%";
        }

        if(!ObjectUtils.isEmpty(mobileNumber)){
            mobileNumber = "%" + mobileNumber + "%";
        }

        return collectorsAssociationMapper.findAssociation(joinStartTime, joinEndTime, province,
                                                                memberName, contactAddress, collectionRange,
                                                                renewalPaymentStartTime, renewalPaymentEndTime, mobileNumber,
                                                                startAge, endAge ,sex);
    }

}
